<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>景点发布</title>
  <{include file="header.html"}>
<style type="text/css">
  #first_a{
  width:241px;
  border:1px solid #CCC;
}
#first_a tr:hover{
  background:#969;
}
#first_a table{
width:100%;
}
#first_a{
  display:none;
}
</style>
    <div id="cont">
        <div id="tban">
            <div id="tban_le">
                <div id="tban_le_01">
                    <img src="../../tpl/images/nlw_dqbg2.jpg" width="10" height="103" />
                </div>
                <div id="tban_le_02">
                    <h1>
                        厦门周边旅游景点
                    </h1>
                    <div id="tban_le_txt">
                        厦门周边旅游景点大全，推荐当季最佳最受欢迎的旅游景点，还有适合周末休闲的好去处。
                    </div>
                </div>
                <div id="tban_le_03">
                    <img src="../../tpl/images/nlw_dqbg4.jpg" width="10" height="103" />
                </div>
            </div>
            <div id="tban_ri">
                <div id="tban_le_01">
                    <img src="../../tpl/images/nlw_dqbg2.jpg" width="10" height="103" />
                </div>
                <div id="tban_le_02">
                    <h1>
                        推荐分类
                    </h1>
                    <div id="tban_le_txt" class="tgray1">
                        厦门周边一日游 厦门周边农家乐 厦门有什么好玩的地方
                    </div>
                </div>
                <div id="tban_le_03">
                    <img src="../../tpl/images/nlw_dqbg4.jpg" width="10" height="103" />
                </div>
            </div>
        </div>
    </div>
    <div id="cont">
        <div id="d_tit06">
            景点发布</div>
        <div id="d_bk_t">
            <div id="d_bk_t01">
                <div class="c1">
                </div>
            </div>
            <div id="d_bk_t02">
                <div class="c1">
                </div>
            </div>
        </div>
            <div id="userinfo_bk">
              <div id="userinfo_bk2">
                <table width="800" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#d1d1d1">
                    <tr>
                        <td width="150" height="55" class="tab_left">
                            标题：
                        </td>
                        <td bgcolor="#FFFFFF" class="tab_right">
                            <input type="text" name="title" class="tab_txt1" id="title" size="60" value="<{$title}>"><span class="torange1"></span>
                        </td>
                    </tr>
                     <tr>
                        <td height="55" class="tab_left">
                            标签：
                        </td>
                        <td bgcolor="#FFFFFF" class="tab_right">
                          <div id="first" class="controls">
                            <input name="tags" type="text" class="tab_txt1" id="tags" value="<{$tags}>" size="60" /><span class="torange1"></span>
                            <div id="first_a"></div>
                          </div>
                        </td>
                    </tr>
                    <tr>
                        <td height="55" class="tab_left">
                            推荐标签：
                        </td>
                        <td bgcolor="#FFFFFF" class="tab_right">
                          <div id="first" class="controls">
                               <{foreach item=chainresultname from=$chainresult key=enname}>
                                  <input name="items" type="checkbox" value="<{$chainresultname.keywords}>" /> <{$chainresultname.keywords}> |
                             <{/foreach}>
                          </div>
                        </td>
                    </tr>

                    <tr>
                        <td height="55" class="tab_left">
                            城市选择：
                        </td>
                        <td bgcolor="#FFFFFF" class="tab_right">
                             <select onchange="province(this)" name="provinceid" id="provinceid">
                             <option selected value="0">无选择省份</option>
                             <{foreach item=resultclassname from=$resultclass key=enname}>
                               <{if $provinceid == $resultclassname.id}>
                                  <option selected value="<{$resultclassname.id}>"><{$resultclassname.citystate}></option>
                               <{else}>
                                  <option value="<{$resultclassname.id}>"><{$resultclassname.citystate}></option>
                               <{/if}>
                             <{/foreach}>
                          </select>
                          <select onchange="area(this)" name="cityid" id="cityid">
                             <option selected value="0">无选择城市</option>
                             <{foreach item=resultsubname from=$resultsub key=enname}>
                               <{if $cityid == $resultsubname.id}>
                                  <option selected value="<{$resultsubname.id}>"><{$resultsubname.citystate}></option>
                               <{else}>
                                  <!-- <option value="<{$resultsubname.id}>"><{$resultsubname.citystate}></option> -->
                               <{/if}>
                             <{/foreach}>
                          </select>
                           <select name="areaid" id="areaid">
                             <option selected value="0">无选择区</option>
                             <{foreach item=resultsubname from=$resultsub key=enname}>
                               <{if $areaid == $resultsubname.id}>
                                  <option selected value="<{$resultsubname.id}>"><{$resultsubname.citystate}></option>
                               <{else}>
                                  <!-- <option value="<{$resultsubname.id}>"><{$resultsubname.citystate}></option> -->
                               <{/if}>
                             <{/foreach}>
                          </select>
                          <span class="torange1"></span>
                        </td>
                    </tr>

                     <tr>
                        <td height="55" class="tab_left">
                            发布人：
                        </td>
                        <td bgcolor="#FFFFFF" class="tab_right">
                            <span><{$username}></span>
                            <input name="username" type="hidden" class="tab_txt1" id="username" size="60" value="<{$username}>" />
                        </td>
                    </tr>

<!--                     <tr>
                        <td height="55" class="tab_left">
                         上传图片：
                        </td>
                        <td bgcolor="#FFFFFF" class="tab_right">
                            <input name="picurl" type="text" class="tab_txt1" id="picurl" size="60" value="<{$picurl}>" /><span></span>
                            <input id="fileupload" type="file" value="上传" name="mypic">
                            <div class="files"></div>
                        </td>
                    </tr>
 -->
                    <tr>
                        <td height="55" class="tab_left">
                            地址：
                        </td>
                        <td bgcolor="#FFFFFF" class="tab_right">
                            <input name="address" type="text" class="tab_txt1" id="address" size="60" value="<{$address}>" /><span class="torange1"></span>
                        </td>
                    </tr>
                     
                   <tr>
                        <td height="55" class="tab_left">
                            门票：
                        </td>
                        <td bgcolor="#FFFFFF" class="tab_right">
                            <input name="tickets" type="text" class="tab_txt1" id="tickets" size="60" value="<{$tickets}>" /><span class="torange1"></span>
                        </td>
                  </tr>

                  <tr>
                        <td height="55" class="tab_left">
                            电话：
                        </td>
                        <td bgcolor="#FFFFFF" class="tab_right">
                            <input name="phone" type="text" class="tab_txt1" id="phone" size="60" value="<{$phone}>" /><span class="torange1"></span>
                        </td>
                  </tr>               

                    <tr>
                        <td height="55" class="tab_left">
                            内容：
                        </td>
                        <td bgcolor="#FFFFFF" class="tab_right">
                            <textarea name="content" id="content" class="tab_txt1" style="width:610px;height:450px;visibility:hidden;"><{$content}></textarea>
                            <span class="torange1"></span>
                        </td>
                    </tr>
                    <tr>
                        <td height="55" class="tab_left"> 
                        </td>
                        <td bgcolor="#FFFFFF" class="tab_right">
                            <a id="ex3button" href="javascript:;"><img src="../../tpl/images/nlw_bt3.gif" width="148" height="36" /></a>
                            <input type="hidden" name="id" id="id" value="<{$id}>">
                        </td>
                    </tr>
                </table>
                </div>
      </div>
  <div id="d_bk_b">
            <div id="d_bk_b01">
                <div class="c1">
                </div>
            </div>
            <div id="d_bk_b02">
                <div class="c1">
                </div>
            </div>
        </div>
    </div>

<script type="text/javascript" src="<{$domain}>/tpl/js/jquery-1.7.0.min.js"></script> 
<script src="../../../kindeditor/kindeditor.js"></script>
<script src="<{$domain}>/artDialog/artDialog.js?skin=default"></script>
<script src="<{$domain}>/artDialog/plugins/iframeTools.js"></script>
<script charset="utf-8" src="../../../kindeditor/lang/zh_CN.js"></script>
<script>
  var editor;
      KindEditor.ready(function(K) {
        editor = K.create('textarea[name="content"]', {
          resizeType : 1,
          allowFileManager : true,
          allowPreviewEmoticons : false,
          allowImageUpload : false,
          items : [
            'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline',
            'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
            'insertunorderedlist', '|', 'emoticons', 'image', 'link']
   });

  K('input[name=getHtml]').click(function(e) {
    alert(editor.html());
  });
  K('input[name=isEmpty]').click(function(e) {
    alert(editor.isEmpty());
  });
  K('input[name=getText]').click(function(e) {
    alert(editor.text());
  });
  K('input[name=selectedHtml]').click(function(e) {
    alert(editor.selectedHtml());
  });
  K('input[name=setHtml]').click(function(e) {
    editor.html('<h3>Hello KindEditor</h3>');
  });
  K('input[name=setText]').click(function(e) {
    editor.text('<h3>Hello KindEditor</h3>');
  });
  K('input[name=insertHtml]').click(function(e) {
    editor.insertHtml('<strong>插入HTML</strong>');
  });
  K('input[name=appendHtml]').click(function(e) {
    editor.appendHtml('<strong>添加HTML</strong>');
  });
  K('input[name=clear]').click(function(e) {
    editor.html('');
  });
});
</script>
<script type="text/javascript">
$(function(){
  $("#first").find(":input").focus().live('keyup',function(){
    //获取keyup传输进来的值
    var nkeys=$.trim($(this).val());
    var nkeybak=$.trim($(this).val());
    nkeys=nkeys.split(",");
    var nkey = nkeys[nkeys.length-1];
    //若值为空则不显示;
    if(nkey==''||nkey==null){
      $("#first_a").hide();
    }else{
      //异步传输
      $.post('<{spUrl c=chainform a=sword}>',{name:nkey},function(v){
        $("#first_a").html(v);
        $("#first_a").show("slow");
        //对生成出来的表格里面的值进行操作
        $("#first_a table tr td").click(function(){
           nkeys.pop();
           if(nkeys.length == 0)
           { $("#tags").val(nkeys.join() + $(this).html() +",") ; }
           else
           { $("#tags").val(nkeys.join() + "," + $(this).html() +",") ; }
          $("#first_a").hide() ;
        })
      });
      
    }
      
  })
})
</script>
<script type="text/javascript">
<!--  
function hotkey()  
{  
  var a=window.event.keyCode;  
  if(a==13)  
  {  
    updata();
  }  
  }// end hotkey  
  document.onkeydown = hotkey; //当onkeydown 事件发生时调用hotkey函数  
  </script>
<script type="text/javascript">
$(document).ready(function(){ // 当页面加载完毕的时候
  // 例子三

  $("input[name=items]").click(function() {  
         //alert($(this).val());
         var newstag = $(this).val(); 
         var tag = $("#tags").val();
         if ($(this).attr("checked")) {  
            $("#tags").val(tag+newstag+",");
         }
         else
         { 
            tag = tag.replace(newstag+",","");
            $("#tags").val(tag);
         }
        
  });  

  $("#ex3button").click(function(){ // "提交"按钮被点击
    // 构造发送的数据，请注意如果获取表单各项的值
    updata();
  });
});

function updata(){

    var formdata = {
      'id' : $('#id').val(),
      'title' : $('#title').val(),
      'username' : $('#username').val(),
      'picurl' : $('#picurl').val(),
      'releasedate' : $('#releasedate').val(),
      'content' : editor.html(),
      'provinceid' : $('#provinceid').val(),
      'cityid' : $('#cityid').val(),
      'areaid' : $('#areaid').val(),
      'address' : $('#address').val(),
      'tickets' : $('#tickets').val(),
      'phone' : $('#phone').val(),
      'map' : $('#map').val(),
      'tags' : $('#tags').val()
    };
    var id  = $('#id').val();  // 根据有没有id 判断是编辑还是增加
    var newId;
    if(id == '')
    {
      // 用$.post发送数据
      $.post('<{spUrl c=sceneryinfoform a=adddata}>', formdata, function(result){
                $('#resulttable').append(result);
          newId =result.match(/^\d.*$/);
          feedback(result,id,newId);

      });
    }
    else
    {
        // 用$.post发送数据
      $.post('<{spUrl c=sceneryinfoform a=editdata}>', formdata, function(result){
        $('#resulttable').append(result); // 返回的数据直接追加到resulttable表格的后面
        //alert(result);
        feedback(result,id);
      }); 
    }
}

function del(id){
    $.get('<{spUrl c=sceneryinfoform a=deldata}>', 'id='+id, function(result){
      $('#ex1result').html(result); // 返回的数据直接显示在id=ex1result的span中。
      if(result == 1)
      {alert('删除成功!!');}else{alert('删除失败!!')}
      window.location.reload(); 
    });
}

// 搜索功能调用
function searchs(){
  var filter = $('#filter').val();
  if(filter != ''){
    window.location.href="index.php?c=sceneryinfoform&a=index&t=scenery&filter="+filter+"";
  }
}

// 分类列出
function Class(nums){
  var filter = $('#filter').val();
  if(nums.value != '')
  {window.location.href="index.php?c=sceneryinfoform&a=index&t=scenery&classid="+nums.value+"&filter="+filter+"";}
}

// 分类列出
function province(id){
 if(id.value != 0)
  {
    var formdata = {
      'id' : id.value
    };
    $.post('<{spUrl c=sceneryinfoform a=subclass}>', formdata, function(result){
      $('#resulttable').append(result);
      //alert(result);
      $("#cityid option").remove();
      var response = eval("("+result+")");
      $("#cityid").append("<option value='0'>请选择城市</option>");
      for(var i in response.cityinfo){
        $("#cityid").append("<option value='"+response.cityinfo[i].id+"'>" + response.cityinfo[i].citystate+ "</option>"); 
      }  
    });
   }
   else
   {alert("你没有选择哦！");}
}
  
// 列出区
function area(id){
  if(id.value != 0)
  {
    var formdata = {
      'id' : id.value
    };
    $.post('<{spUrl c=sceneryinfoform a=subclass}>', formdata, function(result){
      $('#resulttable').append(result);
      //alert(result);
      $("#areaid option").remove();
      var response = eval("("+result+")");
      $("#areaid").append("<option value='0'>请选择区</option>"); 
      for(var i in response.cityinfo){
        $("#areaid").append("<option value='"+response.cityinfo[i].id+"'>" + response.cityinfo[i].citystate+ "</option>"); 
      }  
    });
   }
   else
   {alert("你没有选择哦！");}
}

function syslable(str)
{
  var sts = $("#tags").val();
  $("#tags_tag").val(str.value);
  $('#tags_tag').trigger("focus");
  $('#tags_tag').trigger("blur");
  $(".cho").data("placeholder","Select Frameworks...").chosen();
}
</script>
  <script type="text/javascript" src="../upload/jquery.form.js"></script>
<script type="text/javascript">
$(function () {
  var bar = $('.bar');
  var percent = $('.percent');
  var showimg = $('#showimg');
  var progress = $(".progress");
  var files = $(".files");
  var btn = $(".btn span");
  $("#fileupload").wrap("<form id='myupload' action='../upload/action.php' method='post' enctype='multipart/form-data'></form>");
    $("#fileupload").change(function(){
    $("#myupload").ajaxSubmit({
      dataType:  'json',
      beforeSend: function() {
            showimg.empty();
        progress.show();
            var percentVal = '0%';
            bar.width(percentVal);
            percent.html(percentVal);
        btn.html("上传中...");
        },
        uploadProgress: function(event, position, total, percentComplete) {
            var percentVal = percentComplete + '%';
            bar.width(percentVal);
            percent.html(percentVal);
        },
      success: function(data) {
        files.html("<div id='mypicurl' style='display:none'><b>"+data.name+"("+data.size+"k)</b> <span class='delimg' rel='"+data.pic+"'>删除</span></div>");
        var img = "<{$domain}>/upload/files/"+data.pic;
        showimg.html("<img src='"+img+"'>");
        $("#picurl").val(img);
        art.dialog({
            id: 'KDf435',
            content: '<a id="uppic" target="_blank" href=../upload/index.php?srcurl='+img+'>确定上传图片</a>'
        });
        
      //art.dialog.KDf435.close();
        btn.html("添加附件");
      },
      error:function(xhr){
        btn.html("上传失败");
        bar.width('0')
        files.html(xhr.responseText);
      }
    });
  });
  
  $("#uppic").live({click: function() {  //首页
      
      var list = art.dialog.list;
      for (var i in list) {
          list[i].close();
      };
      $('#mypicurl').css("display","block");
  }});

  $(".delimg").live('click',function(){
    var pic = $(this).attr("rel");
    $.post("../upload/action.php?act=delimg",{imagename:pic},function(msg){
      if(msg==1){
        files.html("删除成功.");
        showimg.empty();
        progress.hide();
      }else{
        alert(msg);
      }
    });
  });
});

function feedback(result,id,newId){
    if(newId == null)
    {
        $('.badge').removeClass('badge badge-info').text('');
        var response = eval("("+result+")");
        for(var i in response){
            $('#' + i).next().addClass('badge badge-info');
            $('#' + i).next().text(response[i].toString());
//      console.log(response[i].toString());
        }
        //$('.badge').text('sdfsd');
    }
    else
    {
        window.location.href="<{spUrl}>scenery/"+newId+".html";
    }
}
</script>

<{include file="footer.html"}>